package com.wuchao.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author wuchao66
 * @Date 2023/10/26 9:26
 * @PackageName:com.wuchao.annotation
 * @ClassName: T
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
public class T {//3w-h
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        //
        A a = new A();
        a.show();
       // a.
        //a.
        //反射注解大题
        //1先反射到对应的类
        Class<ShowMyAnnotation> sm= ShowMyAnnotation.class;
       //实例化
        ShowMyAnnotation sma = sm.newInstance();
        //拿到他的所有方法
        sm.getDeclaredMethods();
        Method show = sm.getDeclaredMethod("show", String.class);
        //反调实例化
        show.invoke(sma,"我是反射");
        //拿到这个方法脑袋上面的所有注解
      if(show.isAnnotationPresent(MyAnnotation.class)){
          MyAnnotation declaredAnnotation = show.getDeclaredAnnotation(MyAnnotation.class);
          Arrays.stream(declaredAnnotation.value()).forEach(xjj-> System.out.println(xjj));

      }
      List list=new ArrayList<String>();
        List<String> le = Arrays.asList(new String[]{"波乐", "蝴蝶", "乐乐猪", "屁屁哎超哥", "朱朱乐"})
                .stream().filter(xjj -> {
                    if (xjj.length() >= 3) {
                        if (xjj.indexOf("乐") != -1) {
                            return true;
                        }
                    }
                    return false;
                }).map(xjj->{
                    xjj=xjj+"1232456";
                    return xjj;
                }).collect(Collectors.toList());
        le.forEach(xjj-> System.out.println(xjj));

//        Annotation[] declaredAnnotations = show.getDeclaredAnnotations();
//        Arrays.stream(declaredAnnotations).forEach(xjj->{
//            //判断是否是对应的注解代表
//            if(){
//
//            }
//        });

    }
}
